package com.youzhi.backend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.youzhi.backend.entity.UserRole;
import com.youzhi.backend.mapper.UserRoleMapper;
import com.youzhi.backend.service.IUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 * 用户角色表 服务实现类
 * </p>
 *
 * @author xumeng
 * @since 2022-11-18
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {


    public List<UserRole> selectByUserIds(List<Object> userIds) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.in("userId", userIds);
        return list(queryWrapper);
    }


    public void deleteByRoleIds(Collection roleIds) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.in("roleId", roleIds);
        remove(queryWrapper);
    }


    public void deleteByUserIds(Collection userIds) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.in("userId", userIds);
        remove(queryWrapper);
    }


}
